package com.yoyo.itravel.dao;

import com.yoyo.itravel.bean.CommentImg;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

/**
 * @Description 评论图片操作持久层接口
 *
 * @author HZX
 * @date 2020/5/14 14:42
 */
@Repository
public interface ICommentImgDao {

    /**
     * @Description 添加评论图片
     *
     * @param commentImg
     * @return int
     */
    @Insert("insert into tb_comment_img(commentImgId,imgPath,sightCommentId) values(#{commentImg.commentImgId},#{commentImg.imgPath},#{commentImg.sightCommentId})")
    int insert(CommentImg commentImg) throws SQLException;

    /**
     * @Description 通过图片id删除评论图片
     *
     * @param commentImgId
     * @return int
     */
    @Delete("delete from tb_comment_img where commentImgId=#{commentImgId}")
    int delete(String commentImgId) throws SQLException;

    /**
     * @Description 过景点id查找景点评论中对应的所有图片
     *
     * @param sightId
     * @return java.util.List<cn.hut.travel.bean.CommentImg>
     */
    @Select("select * from tb_comment_img where sightId=#{sightId}")
    List<CommentImg> selectBySightId(String sightId) throws SQLException;

    /**
     * @Description 通过评论id获得该评论的所有图片
     *
     * @param sightCommentId
     * @return java.util.List<cn.hut.travel.bean.CommentImg>
     */
    @Select("select * from tb_comment_img where sightCommentId=#{sightCommentId}")
    List<CommentImg> selectAllByCommentId(String sightCommentId) throws SQLException;
}
